﻿using System;

namespace ClassExercise
{//日历
    internal class Program
    {
        //定义
        const int monthWidth = 35,monthHeight = 10;

        static void Main(string[] args)
        {
            //定义初始光标
            int x = 0, y = 0;
            for (DateTime theDay = new DateTime(2022, 1, 1); theDay.Year == 2022; theDay = theDay.AddDays(1))
            {
                if ((int)theDay.Day == 1)
                {

                    x = ((theDay.Month - 1) % 3) * monthWidth;
                    y = (theDay.Month - 1) / 3 * monthHeight;
                    //打印月份
                    Console.SetCursorPosition(x+20, y);
                    Console.Write(theDay.Month + "月");
                    y = y + 1;
                    Console.SetCursorPosition(x, y);
                    Console.Write("  日  一  二  三  四  五  六");
                    y = y + 1;
                    //打印每月一号空格
                    x = (int)(theDay.DayOfWeek) * 4 + x;
                    Console.SetCursorPosition(x, y);
                    Console.Write("1".PadLeft(4, ' '));

                }
                //打印天数
                if ((int)theDay.DayOfWeek == 6)
                {
                    if ((int)theDay.Day != 1)
                    {
                        Console.Write(theDay.Day.ToString().PadLeft(4, ' '));

                    }
                    x = x - 24;
                    Console.SetCursorPosition(x, y + 1);
                    y += 1;
                }
                else
                {
                    if ((int)theDay.Day != 1)
                        Console.Write(theDay.Day.ToString().PadLeft(4, ' '));
                    x += 4;
                }
            }
            Console.ReadKey();




        }
    }
}